package xiaoqi.springboot.boot;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import javax.annotation.Resource;
import javax.sql.DataSource;


@SpringBootApplication
public class ApplicationDruidMultiple implements CommandLineRunner {


    private Logger logger = LoggerFactory.getLogger(ApplicationDruidMultiple.class);

    @Resource(name = "user1DataSource")
    private DataSource user1DataSource;

    @Resource(name = "user2DataSource")
    private DataSource user2DataSource;

    public static void main(String[] args) {
        SpringApplication.run(ApplicationDruidMultiple.class, args);
    }

    @Override
    public void run(String... args) throws Exception {
        logger.info("[run][获取数据源: {}]", user1DataSource.getClass());
        logger.info("[run][获取数据源: {}]", user2DataSource.getClass());
    }
}
